package com.cs.pk.codestriker;

import java.io.IOException;

import org.eclipse.swt.widgets.Text;

import com.cs.pk.utils.ClearCaseException;
import com.cs.pk.utils.UtilRepository;

public class Title extends AbstractPopulateList {

	private Text text= null; 
	public Title(Object component) {
		super(component);
		text = (Text)component;
	}

	public String filterOutput() {
		if(result!=null) {
			String tokens[] = result.split("\n");
			result = tokens[tokens.length-1].trim();
	//	return result.toString();
		}
		return result;
	}

	public synchronized void populate(Object payload) throws IOException, InterruptedException, ClearCaseException {
		String activityName = (String)payload;
		String viewDir = (String)UtilRepository.getActivityRelatedViewDir(activityName);
		text.setText(runBatFile(new String[] {UtilRepository.DRIVE+":","cd "+viewDir, "cleartool lsactivity -fmt %[title]p "+ activityName}).trim());
	}
	
	public void clear() {
		text.setText("");
	}

}
